<template>
  <a-col
    v-bind="formitem.type !=='divider'?colAttrs:dividerColAttrs"
    v-show="showItem"
  >
    <a-form-item
      v-bind="itemAttrs"
      :label="formitem.type !=='divider'?label:''"
      v-if="loadItem">
      <slot></slot>
    </a-form-item>
  </a-col>
</template>
<script>

import {FormItemMixin} from './FormItenMixin'
export default {
    name: 'FormitemWapper',
    mixins:[FormItemMixin],
    inject: ['sh'],
    computed: {
      showItem:{
        get(){
          if(this.formitem.type=='hidden'){
            return false
          }else{
            if(!this.formitem.subKey){
              return this.sh[this.formitem.key]
            }else{
              return this.sh[this.formitem.subKey][this.formitem.key]
            }
          }
        }
      },
      loadItem:{
        get(){
          if(!this.formitem.subKey){
            return this.sh[this.formitem.key+"_load"]
          }else{
            return this.sh[this.formitem.subKey][this.formitem.key+"_load"]
          }

        }
      }
    },
    data(){
      return {
        dividerColAttrs:{
          md:24,
          xs:24
        }
      }
    },
  mounted() {
      // 处理分组控件占整行
      if(this.formitem.type ==='divider'){
        this.itemAttrs.labelCol = {
          md:0,
          xs:0
        }
        this.itemAttrs.wrapperCol = {
          md:24,
          xs:24
        }
      }
  }
}
</script>

<style scoped>

</style>